include( 'manifest.lua' );

Msg("\n==============================================\n")
Msg("Flood Gamemode 0.01 initalized!\n")
Msg("Gamemode ready to be played :)\n\n")
Msg("- iRzilla\n")
Msg("==============================================\n\n")

require('round')

function GM:Initialize()
	round.AddEvent(ROUND_BUILD, function()
		
	end)
	
	round.AddEvent(ROUND_FIGHT, function()
		GAMEMODE:RaiseWater()
		GAMEMODE:DisableGod()
	end)
	
	round.AddEvent(ROUND_OVER, function()
		GAMEMODE:LowerWater()
		GAMEMODE:EnableGod()
	end)
end

local water = {}

hook.Add("InitPostEntity", "Flood_SaveWater", function()
	for k, v in pairs(ents.FindByName("water")) do table.insert(water, v) end
end)

function GM:RaiseWater()
	for k, v in pairs( water ) do v:Fire( "Open", "", 0 ) end
end

function GM:LowerWater()
	for k, v in pairs( water ) do v:Fire( "Close", "", 0 ) end
end